package com.flight.test;

import com.flight.bean.AirInfo;
import com.flight.dao.AirInfoDaoImpl;
import com.flight.view.Views;

import java.text.ParseException;
import java.util.List;

public class Main {
    public static void main(String[] args) throws ParseException {
        AirInfoDaoImpl dao = new AirInfoDaoImpl();

        int num = 0;
        do {
            Views views = new Views();
            num = views.Menu();
            switch(num){
                case 1:
                    List<AirInfo> infoAll = dao.getAirInfoAll();
                    views.infoList();
                    views.printAirInfo(infoAll);
                    break;
                case 2:
                    String time = views.beginTime();
                    List<AirInfo> infoList = dao.getByAirDate(time);
                    views.infoList();
                    views.printAirInfo(infoList);
                    break;
                case 3:
                    String address = views.address();
                    List<AirInfo> airInfos = dao.getByAddress(address);
                    views.infoList();
                    views.printAirInfo(airInfos);
                    break;
                case 4:
                    String deleteId = views.delete();
                    int k = dao.deleteAirInfo(deleteId);
                    views.printInfo(k);
                    break;
                case 5:
                    String updateId = views.update();
                    AirInfo airInfo = dao.findByAirId(updateId);
                    AirInfo newAirInfo = views.isAirInfo(airInfo);
                    int i = dao.updateAirInfo(newAirInfo, updateId);
                    views.printInfo(i);
                    break;
                case 0:
                    views.bye();
                    break;

            }
        } while (num!=0);


    }
}
